package Work;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.transform.stream.StreamResult;

/**
 * Servlet implementation class Controle
 */
@WebServlet("/Controle")
public class Controle extends HttpServlet {
	boolean User=false;
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public Controle() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		User u=new User();
		
		if(User == false){
			String name=request.getParameter("textfieldU");
			String pass=request.getParameter("textfieldP");
			User=u.UserLogin(name, pass);
		}
		if(User ==true){
			/* User=false;*/
		}
		if(User==true){
			System.out.println("entre :)");
			request.setAttribute("passName", "1");
			String xml =(new OpenFile().OpenFileXML());
			ModifyXMLFile mXML= new ModifyXMLFile();
			ModifyXMLFileCreate mXMLC = new ModifyXMLFileCreate();
			if(request.getParameter("textfield")!= null && request.getParameter("textfield").length()>0 ){
				mXML.deletNode(request.getParameter("textfield"));
			}
		}
		/*
		if(request.getParameter("textfield2")!= null && request.getParameter("textfield2").length()>0 ){
			mXMLC.deletNode(request.getParameter("textfield2"));
		}
		if(request.getParameter("textfield3")!= null && request.getParameter("textfield3").length()>0 ){
			mXMLC.deletNode(request.getParameter("textfield3"));
		}
		 */


		RequestDispatcher reqDis= request.getRequestDispatcher("index.jsp");
		reqDis.forward(request, response);
	}

}
